This is the basic code. type(i)==list is one way which is really strong to help us make judgement
def find(n):
for i in n:
iftype(i)==listortype(i)==tuple:
find(i)else:
print(i)
find(["b",["asdf",["c",[(1,2,3)]]]])
We can do more on this code, we can print out every letters in string which also use type(i)==str:
def find(n):
for i in n:
iftype(i)==listortype(i)==tuple:
find(i)else:
iftype(i)==str:
for n in i:
print(n)else:
print(i)
find(["b",["asdf",["c",[(1,2,3)]]]])
2.chapter 10
After we learn chapter 10, we know some basic of user alternation that our program can respond to events. In this chapter we learnt three events: First, keypress events. Second,mouse events. Third, Automatic events.
1 wn:
wn is the window net it means at any where of the window can trigger the event. The place of "wn"In keypress events and mouse events it tells where our action will be response. For example, we can change it to let only click at the cusp can trigger the events.
2 onclock
For onclock there is no need to provide the location of mouse but it will automatically run the program. It can only run once or using recursion to repeat.
3 global
Global is define at the outer space so that every functions can use it. All functions can operate it at the same time. It not like local value only exist in one function.
totalvalue1 =0def increment(interval):
global totalvalue1
totalvalue1 += interval
def decrement(interval):
global totalvalue1
totalvalue1 -= interval
for i inrange(100):
increment(2)
decrement(100)print(totalvalue1)
totalvalue2 =0def increment(interval):
totalvalue2 =0
totalvalue2 += interval
def decrement(interval):
global totalvalue2
totalvalue2 -= interval
for i inrange(100):
increment(2)
decrement(100)print(totalvalue2)
The first one global the totalvalue for both functions so both of them can change it. So what we got is100.The second one os different that actually the total value in two functions is deferent , they only have the same name. So what we got is -100
This is the basic code. type(i)==list is one way which is really strong to help us make judgement
We can do more on this code, we can print out every letters in string which also use type(i)==str:
2.chapter 10
After we learn chapter 10, we know some basic of user alternation that our program can respond to events. In this chapter we learnt three events: First, keypress events. Second,mouse events. Third, Automatic events.
1 wn:
wn is the window net it means at any where of the window can trigger the event. The place of "wn"In keypress events and mouse events it tells where our action will be response. For example, we can change it to let only click at the cusp can trigger the events.
2 onclock
For onclock there is no need to provide the location of mouse but it will automatically run the program. It can only run once or using recursion to repeat.
3 global
Global is define at the outer space so that every functions can use it. All functions can operate it at the same time. It not like local value only exist in one function.
The first one global the totalvalue for both functions so both of them can change it. So what we got is100.The second one os different that actually the total value in two functions is deferent , they only have the same name. So what we got is -100